package com.book.manager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.book.manager.model.Book;
import com.book.manager.model.BookStock;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface BookStockMapper extends BaseMapper<BookStock> {

    List<BookStock> listBookStockWithBookIdFree(@Param("bookId")Integer bookId, @Param("limit")int limit);

    BookStock findBookStockWithBookCode(@Param("bookCode")String bookCode);

    /**
     * bookId 对应的书籍总数量
     * @param bookId
     * @return
     */
    int sumBookCount(@Param("bookId")Integer bookId);

    /**
     * bookId 对应的书籍现存数量
     * @param bookId
     * @return
     */
    int sumBookStockCount(@Param("bookId")Integer bookId);
}
